﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MpSoft.Library.BUSS.Customers;
using MpSoft.Library.BUSS.Settings;
using MpSoft.Library.DTO;

namespace MpSoft.Web.Controls.Customer
{
    public partial class ContactControl : System.Web.UI.UserControl
    {
        private void ClearControl()
        {
            foreach (Control c in this.Controls)
            {
                if (c is TextBox)
                    (c as TextBox).Text = string.Empty;

            }
        }

        protected string GetContact()
        {
            return SettingBUSS.GetSettingValue("contact.content", "");
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void cmdContact_Click(object sender, EventArgs e)
        {
            Contact obj = new Contact();
            obj.Fullname = txtFullName.Text;
            obj.Email = txtEmail.Text;
            obj.Company = txtCompany.Text;
            obj.PhoneNumber = txtPhone.Text;
            obj.Address = txtAddress.Text;
            obj.Title = txTitle.Text;
            obj.Content = txtContent.Text;
            if (ContactBUSS.Contact_Add(obj) > 0)
                ClearControl();
            //Response.Redirect(Request.RawUrl);
        }
    }
}